﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using XamlMvp.Controls;
using System.Windows.Interop;
using XamlMvp;
using System.Windows.Threading;
using MvpPhoneApplication.Presenters;

namespace MvpPhoneApplication
{
    public partial class App : MvpApplication
    {
        public App()
        {
            // Standard Silverlight initialization
            InitializeComponent();
        }
        
        protected override void InitializeSettings(Settings settings)
        {
            settings.EnableFrameRateCounter = true;
        }

        protected override void InitializeHydrators(IHydratorBinder hydrators)
        {
            //Hydrators allow your ViewModel to survive Tombstones
        }

        protected override void InitializePresenters(IPresenterBinder presenters)
        {
            presenters.RegisterPage<IViewPage, MainPresenter>((view, state) => new MainPresenter(view));
        }

        protected override void Load(Dispatcher dispatcher)
        {
            //Load your data and services here dispatcher to provide asynchronous loading, or use your own.
        }        

        protected override void StartUp(IPresenterContext context)
        {
            //var setting = context.State["setting"];
            //context.IsTombstone //will always be false here
        }

        protected override void DeHydrate(IPresenterContext context)
        {
            //var setting = context.State["setting"];
            //context.IsTombstone //will always be true here
        }

        protected override void ReHydrate(IPresenterContext context)
        {
            //context.State["setting"] = setting;
            //context.IsTombstone //will always be true here
        }

        protected override void ShutDown(IPresenterContext context)
        {
            //context.State["setting"] = setting;
            //context.IsTombstone //will always be false here
        }

        protected override void LogUnhandledException(ApplicationUnhandledExceptionEventArgs e)
        {
            base.LogUnhandledException(e);
        }

        protected override void NavigationFailed(NavigationFailedEventArgs e)
        {
            base.NavigationFailed(e);
        }

        protected override void InitializePhoneApplicationService(PhoneApplicationService phoneApplicationService)
        {
            base.InitializePhoneApplicationService(phoneApplicationService);
        }

        protected override void AddUriMappings(System.Collections.ObjectModel.Collection<UriMapping> mappings)
        {
            base.AddUriMappings(mappings);
        }
    }
}